/**
 * @param {number[]} nums
 * @return {number}
 */
var lengthOfLIS = function(nums) {
  let ans = 0

  if(nums.length === 0) return 0
  const dp = []
  for(let i = 0; i <= nums.length - 1; i++) {
    if (i === 0){
      dp[i] = 1
    } else if (i === 1) {
      dp[i] = nums[i] > nums[i - 1] ? 2 : 1
    } else {
      dp[i] = 1
      for (let j = 0; j <= i; j++) {
        if (nums[j] < nums[i] && dp[j] + 1 > dp[i]) {
          dp[i] = dp[j] + 1
        }
      }
    }
    if (dp[i] > ans) {
      ans = dp[i]
    }
  }
  return ans
};

console.log(lengthOfLIS([4,10,4,3,8,9]))
